package com.kly.user.db.dao;
import com.fqgj.common.base.BaseMapper;
import com.kly.user.db.dbo.SumUserMsgDBO;
import com.kly.user.db.dbo.UserMessageCountDBO;
import com.kly.user.db.dbo.UserMsgDBO;
import com.kly.user.db.entity.UserMsgEntity;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
* User: linqu
* Date: 2023-05-24
* Time: 10:10:36.872
*/

public interface UserMsgDao  extends BaseMapper<UserMsgEntity> {


    List<UserMsgEntity> selectByFromUserAndToUser(Map<String, Object> var1);

    /**
     * 查询当天存在消息，但无会话记录的数据
     */
    List<UserMsgEntity> listTodayMessageWithoutSession();

    List<UserMsgEntity> selectByUserCode(String fromUserCode, String toUserCode);

    List<SumUserMsgDBO> listUserMsgByFromUserCode(Map<String, Object> var1);

    List<UserMsgEntity> selectTodayMessages(Map<String, Object> var1);


    int selectByCreateDate(Map<String, Object> map);

    /**
     * 根据用户ID读取会话深度
     * @param var
     * @return
     */
    List<SumUserMsgDBO> getUserMsgByFromUserCode(Map<String, Object> var);

    List<UserMsgDBO> selectBySessionIds(List<String> sessionIds, Date todayBeginning);

    List<UserMsgDBO> getAllUserMsgBySessionId(String sessionId, Date todayBeginning);


    List<UserMsgDBO> listTodaySessions(Date todayBeginning);

    Integer updateReplyTimes(Long id, Long replyTimes);

    Integer updateChatterReplyTimes(String fromUserCode, String toUserCode, int replyTimes);

    /**
     * 更新chatter回复时间
     */
    Integer updateReplyTimesIfChatterReplied(String fromUserCode, String toUserCode);

    /**
     * 查询当天与
     * @param modelUserCode
     * @return
     */
     Integer selectTodayMessageCount(String modelUserCode);

    /**
     * 查询聊天用户数
     * queryTodayFlag: 1-查询当天
     */
     Integer querySessionsByModelUserCode(String modelUserCode, Integer queryTodayFlag);

    /**
     * 读取用户当天发送消息数量
     * @param startCount
     * @return
     */
    List<UserMessageCountDBO> selectTodayMessageCountInfo(String chatterCodeString, String modelUserCode,Integer startCount);

    /**
     * 读取所有model
     * @param chatterCode
     * @return
     */
     List<String> selectModelCodes(String chatterCode);

    /**
     * 读取用户发送消息数
     *
     * @param userCode
     * @return
     */
    Integer selectMessageCount(String userCode);

    /**
     * 数据清理
     */
    Integer removeMsg();

    /**
     * 数据备份
     */
    Integer backup();

    /**
     * 获取最近一条消息
     */
    UserMsgEntity getLatestMsg(String sessionId);

}